<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script type="text/javascript" src="/admin/js-css/js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="/admin/js-css/js/jquery.ztree-2.6.min.js" ></script>
		<script type="text/javascript" src="/admin/js-css/js/tree.js" ></script>
		<script type="text/javascript" src="/admin/js-css/js/mx1.0.js"></script>
		<script type="text/javascript" src="/admin/js-css/js/mx1.0.1.js"></script>
		<link rel="stylesheet" href="/admin/plugin/zTreeStyle/zTreeStyle.css" />

	</head>
	<body>
		<div id="tree" class="tree"></div>

		<input type="hidden" id="userid_id" />
		<SCRIPT LANGUAGE="JavaScript">

		var userid ;

		function zTreeOnAsyncSuccess(event, treeId, msg)
		 {
			zTree.openLevel();

		 }
		function showIconForTree(treeId, treeNode) {
   			return !treeNode.isParent;
		};

		//onload
		var	zTree;
		setTimeout(
			function(){
				 // Tree
				var setting = {
					checkable : true,
					checkStyle : "checkbox",
					checkRadioType : "level",
					callback : {
						// click: zTreeOnClick,
						asyncSuccess: zTreeOnAsyncSuccess
					 },
				//默认打开几层节点
				openLevel:3,
				async: true,
				asyncUrl: wwwurl+"/admin/api/DataManagementController/queryChildNodeData_user?userid="+userid,  //获取节点数据的URL地址
				asyncParam: ["name", "id","type"],  //获取节点数据时，必须的数据名称，例如：id、name
				asyncParamOther: ["token",localStorage.getItem("token")] //其它参数 ( key, value 键值对格式)
				};
				var zNodes =[];
				zTree = $("#tree").zTree(setting, zNodes);
				console.log(zTree);
				zTree.expandAll(true);

			}
		,2000);

		//验证必填项
		function verification() {
			return true;
		}


		function getData(){
			let ids = [];
			let tmp = zTree.getCheckedNodes(true);
			for(let a=0;a<tmp.length;a++){
				ids.push(tmp[a].id)
			}
			return {ids:""+ids};
		}



		function setData(data){
			console.log(data.userid);
			userid = data.userid;
			$("#userid_id").val(data.userid);
		}

  </SCRIPT>


	</body>
</html>
